/*
 * AGENT SHERPA
 *  
 * Assignement 2 of the Agent Oriented Software Engineering Course
 * M.Sc. in Advanced Software Engineering (Part-time)
 * University College Dublin www.ucd.ie
 *
 * Copyright (c) 2007 Chris Walsh, Aidan Morrisy and Iain Hull.
 * All rights reserved.
 * 
 * Filename: Main.aps
 * Author:   iain
 * Date:     06 February 2008
 */

package org.agentsherpa.model;

public enum Direction {
    North, South, East, West;

    public Point move(Point point) {
        switch (this) {
        case North:
            return new Point(point.getX(), point.getY() + 1);
        case South:
            return new Point(point.getX(), point.getY() - 1);
        case West:
            return new Point(point.getX() - 1, point.getY());
        case East:
            return new Point(point.getX() + 1, point.getY());
        }
        throw new AssertionError("Cannot move in invalid direction " + this);
    }

    public static Direction valueOfIgnoreCase(String val) {
        for (Direction d : values()) {
            if (d.toString().compareToIgnoreCase(val) == 0) {
                return d;
            }
        }
        throw new IllegalArgumentException(val + " is not a valid Direction");
    }

}
